package com.mdd.car.controller;

import com.mdd.car.params.CarBrandParam;
import com.mdd.car.service.ICarBrandService;
import com.mdd.car.vo.CarBrandVo;
import com.mdd.common.aop.NotPower;
import com.mdd.common.base.page.PageValidate;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validate.IdsValidate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 品牌管理
 *
 * @Description
 * @Author 幻速
 * @Date 2024/3/13 13:43
 **/
@RestController
@RequestMapping("api/system/car/brand")
@Api(tags = "车辆品牌管理")
public class SysCarBrandController {
    @Resource
    ICarBrandService carBrandService;
    @NotPower
    @GetMapping("/all")
    @ApiOperation(value="所有品牌")
    public AjaxResult<List<CarBrandVo>> all() {
        List<CarBrandVo> list = carBrandService.all();
        return AjaxResult.success(list);
    }
    @NotPower
    @GetMapping("/list")
    @ApiOperation(value="品牌列表")
    public AjaxResult<PageResult<CarBrandVo>> list(@Validated PageValidate pageValidate,String brandName) {
        PageResult<CarBrandVo> list = carBrandService.list(pageValidate,brandName);
        return AjaxResult.success(list);
    }
    @NotPower
    @PostMapping("/add")
    @ApiOperation(value="品牌新增")
    public AjaxResult<Object> add(@Validated @RequestBody CarBrandParam carBrandParam) {
        carBrandService.add(carBrandParam);
        return AjaxResult.success();
    }
    @NotPower
    @PostMapping("/edit")
    @ApiOperation(value="品牌编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody CarBrandParam carBrandParam) {
        carBrandService.edit(carBrandParam);
        return AjaxResult.success();
    }
    @NotPower
    @PostMapping("/del")
    @ApiOperation(value="品牌删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdsValidate idValidate) {
        carBrandService.del(idValidate.getIds());
        return AjaxResult.success();
    }
}
